#!/usr/bin/env bash
# desc start - wget https://hello.fe80.cn/bash/website.sh && bash website.sh
# date;2021-0727
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

# 部署文档网站
if [ ! -f "/usr/local/nginx/conf/vhost/docsify.conf" ];then
    cat > /usr/local/nginx/conf/vhost/docsify.conf<<EOF
server
    {
        listen 80;
        listen [::]:80;
        server_name wiki.*;
        index index.html;
        root  /home/wwwroot/docsify;
        error_page   404   /404.html;
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|html|js|css)\$
        {
            expires      1h;
        }
        location ~ /\.
        {
            deny all;
        }
        access_log  /home/wwwlogs/docsify.log;
    }
EOF
    service nginx reload
    git clone git@gitee.com:linzening/jiaoyuzonghe.git /home/wwwroot/docsify
    echo -e "\e[0;32m部署完成\e[0m"
else
    echo -e "\e[0;34m正在更新\e[0m"
    git pull
    echo -e "\e[0;32m更新完成\e[0m"
fi